package priv.pront.code.robot.roboCom_uni;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-07-06 15:04
 */
public class P1109_学生分组 {

    static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static int n, l, r, k = 0, u = 0, v = 0;//定义
    static int[] arr;

    public static void main(String[] args) throws IOException {
        st.nextToken();
        n = (int) st.nval;
        arr = new int[n];
        for (int i = 0; i < n; i++) {
            st.nextToken();
            arr[i] = (int) st.nval;
            k += arr[i];
        }
        st.nextToken();
        l = (int) st.nval;
        st.nextToken();
        r = (int) st.nval;
        if (k / (n * 1.0) < l || k / (n * 1.0) > r) {
            System.out.println(-1);
            return;
        }

        for (int i = 0; i < n; i++) {
            if (arr[i] < l) u += l - arr[i];
            else if (arr[i] > r) v += arr[i] - r;
        }
        System.out.println(Math.max(u, v));

    }
}
